﻿namespace Uber.WebUI
{
    using System;
    using System.Web;
    using System.Web.Security;
    using Core.Security;

    public class FormAuths : IFormsAuthentication
    {
        public void SignIn(string userName, bool createPersistentCookie, string role)
        {
            var authTicket = new FormsAuthenticationTicket(
                1,
                userName,  //user id
                DateTime.Now,
                DateTime.Now.AddDays(30),  // expiry
                createPersistentCookie,
                role,
                "/");

            var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(authTicket));

            if (authTicket.IsPersistent)
                cookie.Expires = authTicket.Expiration;

            HttpContext.Current.Response.Cookies.Add(cookie);
        }
        public void SignOut()
        {
            FormsAuthentication.SignOut();
        }
    }
}